package com.lx.filter;

import javax.servlet.*;
import java.io.IOException;

//只有浏览器转发index.jsp资源时，才会执行该过滤器
//@WebFilter(value = "/index.jsp",dispatcherTypes = DispatcherType.FORWARD)

//浏览器直接请求index.jsp资源时，执行该过滤器（request默认）
//@WebFilter(value = "/index.jsp",dispatcherTypes = DispatcherType.REQUEST)
public class FilterDemo2 implements Filter {
    public void init(FilterConfig config) throws ServletException {

    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        //对request请求消息增强
        System.out.println("请求。。。。");
        //放行
        chain.doFilter(req, resp);
        //对response响应消息增强
        System.out.println("响应.....");
    }

    public void destroy() {
    }

}

